package com.ch999.detect;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;

import com.ch999.baseres.BaseActivity;

/**
 * Created by zhulang on 2017/12/28.
 */

public abstract class BaseDetctActivity extends BaseActivity {
    /**
     * replaceFragment
     *
     * @param resLayId
     * @param fragment
     * @param isAddBackStack
     * @param isAnimation
     */
    protected void replaceFragment(int resLayId, Fragment fragment, boolean isAddBackStack, boolean isAnimation) {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        if (isAnimation) {
            fragmentTransaction.setCustomAnimations(
                    R.anim.slide_in_left,
                    R.anim.slide_out_right,
                    R.anim.slide_in_left,
                    R.anim.slide_out_right);
        }
        fragmentTransaction.replace(resLayId, fragment);
        if (isAddBackStack) {
            fragmentTransaction.addToBackStack(null);
        }
        fragmentTransaction.commit();
    }

}
